//
//  LXNearByView.m
//  跑跑快销
//
//  Created by linxian on 14-4-30.
//  Copyright (c) 2014年 ylife. All rights reserved.
//
#define addBtnW                      60
#import "LXNearByView.h"

@implementation LXNearByView
@synthesize nbTableView, addNewClient ;
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self creatUI];
    }
    return self;
}

- (void)creatUI
{
    if (ISDEVICE7) {
        _upViewY = 64.0;
    }else{
        _upViewY = 44.0;
    }

    [self createUpView1];
}

-(void)showUpView1
{
    _upView[1].hidden = YES;
    _upView[0].hidden = NO;
}

-(void)showUpView2
{
    if (_upView[1]) {
        _upView[0].hidden = YES;
        _upView[1].hidden = NO;
    } else {
        [self createUpView2];
    }
    
}

- (void)createUpView1
{
    _upView[0] = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, ViewHeight - _upViewY)];
    _upView[0].backgroundColor = [UIColor redColor];
    [self addSubview:_upView[0]];
    
    nbTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, _upView[0].frame.size.width, ViewHeight - _upViewY + 44)];
    [_upView[0] addSubview:nbTableView];
    
    // 添加新增客户按钮
    addNewClient = [[UIButton alloc] initWithFrame:CGRectMake(_upView[0].frame.size.width-addBtnW, _upView[0].frame.size.height-addBtnW, addBtnW, addBtnW)];
    addNewClient.tag = 1;
    addNewClient.backgroundColor = [UIColor blueColor];
    [_upView[0] addSubview:addNewClient];
}

- (void)createUpView2
{
    _upView[1] = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, ViewHeight - _upViewY)];
    _upView[1].backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_upView[1]];
    
    UIView *vv = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _upView[1].frame.size.width, ViewHeight - _upViewY + 44)];
    [_upView[1] addSubview:vv];
    
    // 添加新增客户按钮
    addNewClient = [[UIButton alloc] initWithFrame:CGRectMake(_upView[1].frame.size.width-addBtnW, _upView[1].frame.size.height-addBtnW, addBtnW, addBtnW)];
    addNewClient.tag = 1;
    addNewClient.backgroundColor = [UIColor blueColor];
    [_upView[1] addSubview:addNewClient];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
